/*!
 *@file BaseTabBar.qml
 *@brief 自定义TabBar
 *@version 1.0

*/
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0

Rectangle
{
    id : itemrect
    Layout.fillWidth: true
    Layout.fillHeight: true
    color: "#000000"
    property var text: ""
    border.color: "gray"
    border.width: isclicked ? 0:1
    property int index: 0

    property bool isclicked: false
    signal mclicked(int index);  //自定义信号
    function clearColor() {
        color = "#fff"
        isclicked = false
    }
    function clicked_handle() {
        color = "#9DCBA8"
        mclicked(index);
        isclicked = true
    }
    Text {
        anchors.centerIn: parent
        text: itemrect.text
        //color: "white"
    }

    MouseArea{
        anchors.fill: parent
        hoverEnabled: true
        propagateComposedEvents:true
        onClicked: {
            clicked_handle()
        }
        onEntered:{
            if (!isclicked)
                parent.color = "#767C7C"
        }

        onExited: {
            if (!isclicked)
                parent.color = "#fff"
        }

    }
}
